package com.mida.app.knw.controller;

import com.mida.app.knw.service.KnwConceptualDetailService;
import com.mida.dms.knw.api.KnwConceptualDetailApi;
import com.mida.dms.knw.entity.KnwConceptualDetail;
import com.mida.dms.knw.entity.vo.KnwConceptualDetailVo;
import com.mida.dms.knw.vo.KnwConceptualDetailPageVo;
import com.mida.dms.knw.vo.PageResultVo;
import com.mida.tool.common.result.ActionResult;
import com.mida.tool.common.result.ListResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: KnwConceptualDetailController
 * @Description: 概念描述
 * @Author: wang xiao le
 * @Date: 2021/6/22 17:20
 **/
@RestController
@RequestMapping("/knwConceptualDetail")
@CrossOrigin
public class KnwConceptualDetailController {
    @Autowired
    private KnwConceptualDetailApi knwConceptualDetailApi;

    @Autowired
    private KnwConceptualDetailService knwConceptualDetailService;

    /**
     * 1、新增概念描述
     */
    @PostMapping(value = "/addKnwConceptualDetail", produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public ActionResult add(@RequestParam(value = "conceptualSoid") Long conceptualSoid,
                            @RequestParam(value = "conceptualDetailSoid") Long conceptualDetailSoid,
                            @RequestParam(value = "conceptualDetailName") String conceptualDetailName,
                            @RequestParam(value = "isPreferred") Long isPreferred,
                            @RequestParam(value = "languageSoid") Long languageSoid,
                            @RequestParam(value = "conceptualDetailType") Long conceptualDetailType,
                            @RequestParam(value = "status") Long status) {
        return knwConceptualDetailApi.add(conceptualSoid,
                conceptualDetailSoid,
                conceptualDetailName,
                isPreferred, languageSoid, conceptualDetailType, status);

    }

    /**
     * 2、更新概念描述
     */
    @PostMapping(value = "/updateKnwConceptualDetail", produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public ActionResult update(@RequestParam(value = "conceptualSoid") Long conceptualSoid,
                               @RequestParam(value = "conceptualDetailSoid") Long conceptualDetailSoid,
                               @RequestParam(value = "conceptualDetailName") String conceptualDetailName,
                               @RequestParam(value = "isPreferred") Long isPreferred,
                               @RequestParam(value = "languageSoid") Long languageSoid,
                               @RequestParam(value = "conceptualDetailType") Long conceptualDetailType,
                               @RequestParam(value = "status") Long status) {
        return knwConceptualDetailApi.update(conceptualSoid,
                conceptualDetailSoid,
                conceptualDetailName,
                isPreferred, languageSoid, conceptualDetailType, status);
    }

    /**
     * 3、删除概念描述
     */
    @ApiOperation(value = "删除概念描述", notes = "删除概念描述")
    @GetMapping(value = "/deleteKnwConceptualDetail")
    @ResponseBody
    public ActionResult delete(long soid) {
        return knwConceptualDetailApi.delete(soid);
    }

    /**
     * 4、 获取概念描述
     */
    @ApiOperation(value = "获取概念描述", notes = "获取概念描述")
    @ApiImplicitParam(name = "soid", value = "概念描述soid", required = false)
    @GetMapping(value = "/getKnwConceptualDetail")
    @ResponseBody
    public ListResult<KnwConceptualDetail> get(long soid) {
        return knwConceptualDetailApi.get(soid);
    }

    /**
     * 5、分页查询概念描述
     */
    @ApiOperation(value = "分页查询概念描述", notes = "分页查询概念描述")
    @PostMapping(value = "/findPage", produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public ListResult<PageResultVo<KnwConceptualDetailVo>> findPage(@RequestParam(value = "currentPage") Long currentPage,
                                                                    @RequestParam(value = "pageSize") Long pageSize,
                                                                    @RequestParam(value = "searChData") String searChData,
                                                                    @RequestParam(value = "conceptualSoid") Long conceptualSoid) {
        return knwConceptualDetailService.findPage(currentPage,pageSize,searChData,conceptualSoid);
    }

    /**
     * 6、检查名称
     */
    @ApiOperation(value = "检查名称", notes = "检查名称")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "soid", value = "概念描述soid", required = false),
            @ApiImplicitParam(name = "name", value = "概念描述名称", required = false)
    })
    @GetMapping(value = "/checkName")
    @ResponseBody
    public ActionResult checkName(Long soid, String name) {
        return knwConceptualDetailApi.checkName(soid, name);
    }

    /**
     * 7、设置概念描述首选
     */
    @ApiOperation(value = "设置概念描述首选", notes = "设置概念描述首选")
    @ApiImplicitParam(name = "soid", value = "概念描述soid", required = false)
    @GetMapping(value = "/setFirst")
    @ResponseBody
    public ActionResult setFirst(Long soid, Long conceptualSoid, Long isConceptualDomain) {
        return knwConceptualDetailApi.setFirst(soid, conceptualSoid, isConceptualDomain);
    }
}
